/*
 * Various utilities that don't have a better home.
 * 
 */



#ifndef UTILITIES_HPP
#define UTILITIES_HPP

#include <string>
#include <unistd.h>
#include <vector>
#include <boost/iterator/iterator_concepts.hpp>
#include <iostream>

namespace utilities
{       
    /*
     *  * TODO put this in its own file.
    */
    void loadStylesheet(const char* filename);

    /*
     * Store the executable pathname in a singleton because I need to know it
     * sometimes. Not sure if there's a more elegant solution atm.
     */
    class SRootDirectory
    {
        SRootDirectory(SRootDirectory const&);              
        void operator=(SRootDirectory const&);
        SRootDirectory();
        
        static SRootDirectory   *s_instance;
        std::string             m_path;
        
    public:
        static SRootDirectory *instance()
        {
            if (!s_instance)
                s_instance = new SRootDirectory;
            return s_instance;
        }
        
        std::string get_path()
        {
            return m_path;
        }
    };
    
    
    class ModifiedArgv
    {
        char**  m_argv;
        int     m_count;
        
        std::vector<std::string> m_temp_storage; 
        
    public:
        ~ModifiedArgv()
        {
            if (m_argv != nullptr)
            {
                delete [] m_argv;
            }
        }
        
        ModifiedArgv(int argc, char *argv[]);
        
        char** getArgs();
        
        inline std::string getItem(int n) { return m_temp_storage[n]; }
        
        int getArgsSize() { return m_temp_storage.size(); }
    };
}


#endif